import Vue from 'vue'
import VueRouter from 'vue-router'
import Tool from '@/pages/tool/Tool'
import Home from '@/pages/tool/home/Home'
import Order from '@/pages/tool/order/Order'
import Mine from '@/pages/tool/mine/Mine'
import Login from '@/pages/login/Login'
import Detail from '@/pages/detail/Detail'
import Msg from '@/pages/msg/Msg'
import Bargain from '@/pages/msg/components/parts/Bargain'
import Remind from '@/pages/msg/components/parts/Remind'
import Email from '@/pages/msg/components/parts/Email'
import Result from '@/pages/msg/components/parts/Result'
import Search from '@/pages/search/Search'
import Helps from '@/pages/helps/Helps'
import List from '@/pages/list/List'
import Collection from '@/pages/collection/Collection'
import Counter from '@/pages/counter/Counter'
import Discount from '@/pages/counter/Discount'
import Shopping from '@/pages/counter/Shopping'
import Onshelf from '@/pages/counter/Onshelf'
import Register from '@/pages/register/Register'
import Sale from '@/pages/sale/Sale'
import Worth from '@/pages/worth/Worth'
import Roles from '@/pages/roles/Roles'
import Character from '@/pages/detail/components/parts/Character'
import Equipment from '@/pages/detail/components/parts/Equipment'
import Skill from '@/pages/detail/components/parts/Skill'
import Pet from '@/pages/detail/components/parts/Pet'
import Other from '@/pages/detail/components/parts/Other'

Vue.use(VueRouter)

const routes = [{
        path: '/tool',
        name: 'Tool',
        component: Tool,
        children: [{
                path: 'home',
                name: 'Home',
                component: Home
            },
            {
                path: 'order',
                name: 'Order',
                component: Order
            },
            {
                path: 'mine',
                name: 'Mine',
                component: Mine
            }, {
                path: '',
                component: Home
            }
        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/detail',
        name: 'Detail',
        component: Detail,
        redirect: '/detail/character',
        children: [{
                path: 'character',
                name: 'Character',
                component: Character
            },
            {
                path: 'Equipment',
                name: 'Equipment',
                component: Equipment
            },
            {
                path: 'Pet',
                name: 'Pet',
                component: Pet
            },
            {
                path: 'Skill',
                name: 'Skill',
                component: Skill
            },
            {
                path: 'Other',
                name: 'Other',
                component: Other
            }
        ]
    },
    {
        path: '/msg',
        name: 'Msg',
        component: Msg
    },
    {
        path: '/bargain',
        name: 'Bargain',
        component: Bargain
    },
    {
        path: '/remind',
        name: 'Remind',
        component: Remind
    },
    {
        path: '/email',
        name: 'Email',
        component: Email
    },
    {
        path: '/result',
        name: 'Result',
        component: Result
    },
    {
        path: '/search',
        name: 'Search',
        component: Search
    },
    {
        path: '/counter',
        name: 'Counter',
        component: Counter
    },
    {
        path: '/onshelf',
        name: 'Onshelf',
        component: Onshelf
    },
    {
        path: '/shopping',
        name: 'Shopping',
        component: Shopping
    },
    {
        path: '/discount',
        name: 'Discount',
        component: Discount
    },
    {
        path: '/helps',
        name: 'Helps',
        component: Helps
    },
    {
        path: '/list',
        name: 'List',
        component: List
    },
    {
        path: '/collection',
        name: 'Collection',
        component: Collection
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },
    {
        path: '/sale',
        name: 'Sale',
        component: Sale
    },
    {
        path: '/worth',
        name: 'Worth',
        component: Worth
    },
    {
        path: '/roles',
        name: 'Roles',
        component: Roles
    },
    {
        path: '*',
        redirect: '/tool/home'
    }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

//解决vue3.0以上重复点击菜单报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router